package com.dxyxx.framework;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.customized.CountDownButtonHelper;
import com.android.customized.CountDownButtonHelper.OnFinishListener;
import com.dxyxx.R;

public class RegisterActivity extends BaseActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_register);
		EditText phone = (EditText) findViewById(R.id.username);
		phone.setSelectAllOnFocus(true);
		phone.setFocusable(true);
		phone.setFocusableInTouchMode(true);

		EditText code = (EditText) findViewById(R.id.code);
		code.setSelectAllOnFocus(true);
		code.setFocusable(true);
		code.setFocusableInTouchMode(true);
		
		EditText password = (EditText) findViewById(R.id.password);
		password.setSelectAllOnFocus(true);
		password.setFocusable(true);
		password.setFocusableInTouchMode(true);
		
		EditText repeatPassword = (EditText) findViewById(R.id.repeatPassword);
		repeatPassword.setSelectAllOnFocus(true);
		repeatPassword.setFocusable(true);
		repeatPassword.setFocusableInTouchMode(true);

		initViews();
	}

	private Button btn;

	private void initViews() {
		((ImageView) findViewById(R.id.backImageButton)).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		((ImageView) findViewById(R.id.nextImageButton)).setVisibility(View.INVISIBLE);
		TextView titleView = (TextView) findViewById(R.id.title);
		titleView.setText("注册大象与猩猩用户");
		titleView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
		// 点击发送验证码。。等待30秒
		btn = (Button) findViewById(R.id.b_send);
		btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				CountDownButtonHelper helper = new CountDownButtonHelper(btn, "倒计时", 30, 1);
				helper.setOnFinishListener(new OnFinishListener() {

					@Override
					public void finish() {
						Toast.makeText(RegisterActivity.this, "倒计时结束", Toast.LENGTH_SHORT).show();
					}
				});
				helper.start();

			}
		});
	}
}
